package com.kf.bigbluebook.common;

import com.kf.bigbluebook.exception.BusinessException;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 统一返回对象
 * @param <T>
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class BaseResponse<T> implements Serializable {
    //返回码
    private int code;
    //返回数据
    private T data;
    //返回消息
    private String message;
    //返回状态描述
    private String description;
    public BaseResponse(ErrorCode errorCode) {
        this(errorCode.getCode(),null,errorCode.getMessage(),errorCode.getDescription());
    }
    public BaseResponse(BusinessException e){
        this(e.getCode(),null,e.getMessage(),e.getDescription());
    }

}
